Developer --> Technical Publications
PATHJava Developer Documentation > Mac OS Runtime for Java > JManager > Programming With JManager


Obtaining Java References

In some cases, you may need to access the actual Java objects used in a session, rather than the encapsulated objects passed by the embedding application. For example, if you wanted to call a method contained in an instantiated frame, you would need a reference to the actual Java frame, not the JMFrameRef object. Table 1-2 lists the functions you can use to return Java references. These functions all return a pointer of type jobject .

Table 1-2 Functions that return pointers to Java objects

Function

Returns pointer to object

JMGetSessionJNIObject com.apple.mrj.JManager.JMSession
JMGetAwtContextJNIObject com.apple.mrj.JManager.AWTContext
JMGetAppletViewerJNIObject com.apple.mrj.JManager.JMAppletViewer
JMGetJMFrameJNIObject com.apple.mrj.JManager.JMFrame
JMGetAppletJNIObject java.applet.Applet
JMGetAWTFrameJNIObject java.awt.Frame

The first four functions return the jobject equivalents of the corresponding JManager objects. For example, JMGetSessionJNIObject returns the equivalent of the JMSessionRef reference. JMGetAppletJNIObject and JMGetAWTFrameJNIObject , however, return references to their actual Java objects.

You can use these references directly if you are accessing the Java Native Interface (JNI), but if you need to access the Java Runtime Interface (JRI), you must convert references of type jobject to ones of type jref using the JMJNIObjectToJRIRef function JMJNIObjectToJRIRef. To convert references of type jref to type jobject , use The JMJRIRefToJNIObject function.

Note

MRJ may not support the Java Runtime Interface (JRI) in the future. Unless you specifically need to use the JRI, you should use the Java Native Interface (JNI) instead.


© 1998 Apple Computer, Inc. — (Last Updated 3 Dec 98)

Previous | Back Up One Level | Next |